package com.ruoyi.blog.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.blog.mapper.BlogAccessMapper;
import com.ruoyi.blog.domain.BlogAccess;
import com.ruoyi.blog.service.IBlogAccessService;

/**
 * 访问Service业务层处理
 *
 * @author tina
 * @date 2021-06-27
 */
@Service
public class BlogAccessServiceImpl implements IBlogAccessService
{
    @Autowired
    private BlogAccessMapper blogAccessMapper;

    /**
     * 查询访问
     *
     * @param id 访问ID
     * @return 访问
     */
    @Override
    public BlogAccess selectBlogAccessById(Long id)
    {
        return blogAccessMapper.selectBlogAccessById(id);
    }

    /**
     * 查询访问列表
     *
     * @param blogAccess 访问
     * @return 访问
     */
    @Override
    public List<BlogAccess> selectBlogAccessList(BlogAccess blogAccess)
    {
        return blogAccessMapper.selectBlogAccessList(blogAccess);
    }

    /**
     * 新增访问
     *
     * @param blogAccess 访问
     * @return 结果
     */
    @Override
    public int insertBlogAccess(BlogAccess blogAccess)
    {
        blogAccess.setCreateTime(DateUtils.getNowDate());
        return blogAccessMapper.insertBlogAccess(blogAccess);
    }

    /**
     * 修改访问
     *
     * @param blogAccess 访问
     * @return 结果
     */
    @Override
    public int updateBlogAccess(BlogAccess blogAccess)
    {
        blogAccess.setUpdateTime(DateUtils.getNowDate());
        return blogAccessMapper.updateBlogAccess(blogAccess);
    }

    /**
     * 批量删除访问
     *
     * @param ids 需要删除的访问ID
     * @return 结果
     */
    @Override
    public int deleteBlogAccessByIds(Long[] ids)
    {
        return blogAccessMapper.deleteBlogAccessByIds(ids);
    }

    /**
     * 删除访问信息
     *
     * @param id 访问ID
     * @return 结果
     */
    @Override
    public int deleteBlogAccessById(Long id)
    {
        return blogAccessMapper.deleteBlogAccessById(id);
    }

    /**
     * 统计访问数量
     * @param articleId 文章ID
     * @return
     */
    @Override
    public int countAccessById(Long articleId) {
        return blogAccessMapper.countAccessById(articleId);
    }
}